package com.zygh.lz.controller.pc;

import cn.hutool.core.date.DateUtil;
import com.zygh.lz.entity.InformationUser;
import com.zygh.lz.service.impl.InformationUserService;
import com.zygh.lz.stapprove.ResultUtil;
import com.zygh.lz.vo.ResultBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(tags = "消息和人员关联")
@RestController
@RequestMapping("/InformationUserController")
public class InformationUserController {

    @Resource
    private InformationUserService informationUserService;

    @ApiOperation("根据消息id查询接收人情况")
    @GetMapping("findInforUserById")
    public ResultBean findInforUserById(Integer id) {
        return informationUserService.findInforUserById(id);

    }

    @ApiOperation("根据人员警号查询接收的消息")
    @GetMapping("findInforUserByWarningSignal")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "pageNum", value = "页码", dataType = "Integer", required = true),
            @ApiImplicitParam(name = "pageSize", value = "每页数量", dataType = "Integer", required = true)

    })
    public ResultBean findInforUserByWarningSignal(String warningSignal, String startTime, String endTime,
                                                   @RequestParam(defaultValue = "1") int pageNum,
                                                   @RequestParam(defaultValue = "15") int pageSize) {
        return informationUserService.findInforUserByWarningSignal(warningSignal, startTime, endTime, pageNum, pageSize);

    }

    @GetMapping("test")
    public void test(){
        InformationUser informationUser = new InformationUser();
        informationUser.setAcceptWarningSignal("100728")
                .setInformationId(110)
                .setIsRead(false)
                .setName("y让峰哥")
                .setUpdateTime(DateUtil.now());
        informationUserService.insert(informationUser);
    }





}
